package com.example.admin.yuejian21.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.admin.yuejian21.R;
import com.example.admin.yuejian21.Service.Service;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static com.example.admin.yuejian21.Adapter.PicAdapter.picid;
import static com.example.admin.yuejian21.Adapter.PicAdapter.picuserid;
import static com.example.admin.yuejian21.activity.LoginActivity.userid;

public class yjActivity extends AppCompatActivity {
        private Button yjButton;
        private EditText contact;
        private EditText context;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_yj);
        contact= (EditText) findViewById(R.id.editText3_callway);
        context= (EditText) findViewById(R.id.editText4_fkyj);
        yjButton= (Button) findViewById(R.id.button3_submit);
        yjButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //拿到用户输入的用户名、密码.
                String callway = contact.getText().toString();
                String content=context.getText().toString();


                Retrofit retrofit = new Retrofit.Builder()
                        .addConverterFactory(GsonConverterFactory.create())
                        .baseUrl("http://172.24.10.175/workout/api.php/")
                        .build();

                Service service = retrofit.create(Service.class);
                Call<Integer> call = service.yj(content,callway);

                //3. 发送请求
                call.enqueue(new Callback<Integer>(){

                    @Override
                    public void onFailure(Call<Integer> arg0, Throwable arg1) {
                        Toast.makeText(yjActivity.this, "反馈失败", Toast.LENGTH_SHORT).show();

                    }
                    @Override
                    public void onResponse(Call<Integer> call, Response<Integer> response) {
                        if(response.body()!=0)


                        {
                            Toast.makeText(yjActivity.this, "反馈成功", Toast.LENGTH_SHORT).show();
                            ;



                        }
                    }

                });
            }
        });
    }
}
